using System;
using ValidationFramework;

namespace ExampleLibraryCSharp
{

	public class EnumConversionRuleAttributeExample
    {

		public enum Numbers
		{
			One,
			Two,
			Three
        }


        #region using string values
        [EnumConversionRule("ExampleLibraryCSharp.EnumConversionRuleAttributeExample+Numbers, ExampleLibraryCSharp",ErrorMessage = "Invalid enum format.")]
        public string EnumString1
        {
            get;
            set;
        }

        private static readonly RuntimeMethodHandle parseEnum1Handle =
			typeof(EnumConversionRuleAttributeExample).GetMethod("ParseEnum1").MethodHandle;

		public void ParseEnum1([EnumConversionRule("ExampleLibraryCSharp.EnumConversionRuleAttributeExample+Numbers, ExampleLibraryCSharp")] string enumString)
        {
			ParameterValidationManager.ThrowException(this, parseEnum1Handle, enumString);
        }
        #endregion

        #region Using strong typing

        [EnumConversionRule(typeof(Numbers),ErrorMessage = "Invalid enum format.")]
        public string EnumString2
        {
            get;
            set;
        }

        private static readonly RuntimeMethodHandle parseEnum2Handle =
			typeof(EnumConversionRuleAttributeExample).GetMethod("ParseEnum2").MethodHandle;

        public void ParseEnum2([EnumConversionRule(typeof(Numbers))] string enumString)
        {
			ParameterValidationManager.ThrowException(this, parseEnum2Handle, enumString);
        }
        #endregion
    }
}